package com.pitop.user.ctrl;

import com.pitop.user.entity.UserInfo;
import com.pitop.user.service.UserInfoFeignSV;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/userinfo")
@Slf4j
public class UserInfoCtrl {

    @Autowired
    private UserInfoFeignSV userInfoFeignSV;

    @ApiOperation(value = "pps-cloud系统用户信息模块根据ID获取信息", notes = "swagger测试")
    @ApiImplicitParam(name = "id", value = "id", dataType = "Integer", required = true, paramType = "query")
    @RequestMapping(value = "/getById", method = RequestMethod.GET)
    @ResponseBody
    public UserInfo getById(Integer id) {
        UserInfo userInfoEntity = userInfoFeignSV.getById(id);
        return userInfoEntity;
    }

    @ApiOperation(value = "pps-cloud系统用户信息模块根据userName获取信息", notes = "swagger测试")
    @ApiImplicitParam(name = "userName", value = "userName", dataType = "String", required = true, paramType = "query")
    @RequestMapping(value = "/getByName", method = RequestMethod.GET)
    @ResponseBody
    public List<UserInfo> getByName(String userName) {
        return userInfoFeignSV.getByName(userName);
    }

    @ApiOperation(value = "pps-cloud系统用户信息模块根据roleId获取信息", notes = "swagger测试")
    @ApiImplicitParam(name = "roleId", value = "roleId", dataType = "Integer", required = true, paramType = "query")
    @RequestMapping(value = "/getByRoleId", method = RequestMethod.GET)
    @ResponseBody
    public List<UserInfo> getByRoleId(Integer roleId) {
        return userInfoFeignSV.getByRoleId(roleId);
    }

    @ApiOperation(value = "pps-cloud系统用户信息模块根据roleName获取信息", notes = "swagger测试")
    @ApiImplicitParam(name = "roleName", value = "roleName", dataType = "String", required = true, paramType = "query")
    @RequestMapping(value = "/getByRoleName", method = RequestMethod.GET)
    @ResponseBody
    public List<UserInfo> getByRoleName(String roleName) {
        return userInfoFeignSV.getByRoleName(roleName);
    }

}
